import request from '../utils/request'

// 加入购物车
// goodsId: 商品id
// goodsNum: 商品数量
// goodsSkuId: 商品规格Id
export const addCart = (goodsId, goodsNum, goodsSkuId) => {
  return request.post('http://smart-shop.itheima.net/index.php?s=/api/cart/add', {
    goodsId,
    goodsNum,
    goodsSkuId
  })
}

// 获取购物车列表
export const getCartList = () => {
  return request.get('http://smart-shop.itheima.net/index.php?s=/api/cart/list')
}

// 更新购物车商品数量
export const changeCount = (goodsId, goodsNum, goodsSkuId) => {
  return request.post('http://smart-shop.itheima.net/index.php?s=/api/cart/update', {
    goodsId,
    goodsNum,
    goodsSkuId
  })
}

// 删除购物车商品
export const deleteCart = (cartIds) => {
  return request.post('http://smart-shop.itheima.net/index.php?s=/api/cart/clear', {
    cartIds
  })
}

// 获取购物车商品总数量
export const getCartTotal = () => {
  return request.get('https://smart-shop.itheima.net/index.php?s=/api/cart/total')
}
